/**
 * 
 */
package com.org.javabody.Java_To_Json.JsonArrayCompareTo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

/**

 * @author Administrator

 *

 */
public class Json_equal {

	public static String getJson_1() {
		List<HashMap<String,Object>> list = new ArrayList<HashMap<String,Object>>();
		for(int i=0; i < 2;i++){
			HashMap<String,Object> map = new HashMap<String,Object>();
			map.put("aac001", i);
			map.put("aac003", "甘恒旭");
			map.put("aac004", "男");
			map.put("aac006", "1992-11-13");
			map.put("aae058", "15000000.00");
			list.add(map);
		}
		String json = JSONArray.fromObject(list).toString();
		return json;
	}
	
	public static String getJson_2() {
		List<HashMap<String,Object>> list = new ArrayList<HashMap<String,Object>>();
		for(int i=0; i < 2;i++){
			HashMap<String,Object> map = new HashMap<String,Object>();
			map.put("aac001", i);
			map.put("aac006", "1992-11-13");			
			map.put("aac004", "男");
			map.put("aac003", "甘恒旭");
			map.put("aae058", "15000000.00");
			list.add(map);
		}
		String json = JSONArray.fromObject(list).toString();
		return json;
	}
	
	public static void json_to_list() {
		String a = getJson_1();
		JSONArray js = JSONArray.fromObject(a);
		System.out.println(js);
		for(int i = 0; i<js.size(); i++) {
			JSONObject json = js.getJSONObject(i);
			System.out.println(json.get("aac001"));
		}
	}
	
	
	public static void print(){
		String a = getJson_1();
		String b = getJson_2();
		System.out.println("compareTo:"+a.compareTo(b));//与次序无关

		System.out.println("equal:"+a.equals(b));//与次序无关

	}
	
	/**

	 * @param args

	 */
	public static void main(String[] args) {
		print();
		json_to_list();
	}
}
